from modules.admin.models.Category import Category
from schemas.category import Create, Update


class CategoryServices:
    @staticmethod
    def create(form: Create):
        data = Category.create(**form.model_dump())
        return data

    @staticmethod
    def get_all():
        data = Category.all()
        return data



    @staticmethod
    def get_one(Id: int):
        data = Category.find(Id)
        return data

    @staticmethod
    def update(form: Update, category_id: str):
        data = Category.find(category_id)
        data.update(form.model_dump())
        return data

    @staticmethod
    def delete(Id):
        data = Category.find(Id)
        data.delete()
        return data
